#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by master on 2017/3/5
import sys


class WebServer(object):
    def __init__(self, host, port):
        self.host = host
        self.port = port

    def start(self):
        print("Server is starting...")

    def stop(self):
        print("Server is stopping...")

    def restart(self):
        self.stop()
        self.start()


def test_run(ins, name):
    print("running...", ins.host)


if __name__ == '__main__':
    server = WebServer("localhost", 3333)
'''

    cmd_dict = {
        "start": server.start(),
        "stop": server.stop(),
    }
    if sys.argv[1] in cmd_dict:
        cmd_dict[sys.argv[1]]()
'''
'''
if hasattr(server, sys.argv[0]):
    func = getattr(server, sys.argv[0])  # 获取server.start的内存地址
    func()
setattr(server, "run", test_run)  # 给server实例绑定了test_run方法 调用时如果需要实例的成员则需要传入当前实例

server.run(server, "alex")
'''
delattr(server, "host")  # 删除成员
